package com.ltx.blog_bam.controller;


import com.alibaba.fastjson.JSONObject;
import com.ltx.blog_bam.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    /***
     * 用于用户的登录请求，三种情况一共有用户不存在，密码错误，登录成功
     * @param param
     * @return
     */
    @PostMapping("/Login")
    private String Login(@RequestBody JSONObject param){
        String userName = param.getString("userName");
        String userPwd = param.getString("userPwd");
        if(userService.userExit(userName)){
            if(userService.CheckPwd(userName,userPwd)){
                return "登录成功";
            }else {
                return "密码错误";
            }
        }else {
            return "用户不存在";
        }
    }


}
